using System;
using System.Linq;
using System.Collections.Generic;
using DevExpress.CodeRush.StructuralParser;
using CR.StyleCop;

namespace CR.StyleCop.Maintainability {
    public class FileMayOnlyContainASingleClass : BaseStyleCopIssueSearcher<IClassElement> {

        public override IEnumerable<StyleCopIssue> FindIssues(IEnumerable<IClassElement> elements) {
            if (elements.Count() <= 1)
                return Utils.SourceUtils.EmptyIssueList;

            return elements.Skip(1).Select(c => new StyleCopIssue { 
                Element = c, 
                IssueDescription = Resource.FileMayOnlyContainASingleClassIssueDescription
            });
        }
    }
}
